<!DOCTYPE html>
<html lang="en">
    <head>
	    <meta charset="utf-8">
	    <title>后台管理系统</title>
	    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
	    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	    <meta name="description" content="">
	    <meta name="author" content="">
	    {load href="/static/css/bootstrap.css" /}
	    {load href="/static/css/theme.css" /}
	    {load href="/static/css/font-awesome.css" /}
	    {load href="/static/js/jquery-1.7.2.min.js" /}
	    {load href="/static/js/laydate.js" /}
	    <!-- Demo page code -->
	    <style type="text/css">
	        #line-chart {
	            height:300px;
	            width:800px;
	            margin: 0px auto;
	            margin-top: 1em;
	        }
	        .brand { font-family: georgia, serif; }
	        .brand .first {
	            color: #ccc;
	            font-style: italic;
	        }
	        .brand .second {
	            color: #fff;
	            font-weight: bold;
	        }
	        *{margin:0;padding:0;list-style:none;}
			html{background-color:#E3E3E3; font-size:14px; color:#000; font-family:'微软雅黑'}
			.laydate-icon{width:220px;display:inline-block;}

			/*html, body, div, span, object, iframe,
			h1, h2, h3, h4, h5, h6, p, blockquote, pre,
			abbr, address, cite, code,
			del, dfn, em, img, ins, kbd, q, samp,
			small, strong, sub, sup, var,
			b, i,
			dl, dt, dd, ol, ul, li,
			fieldset, form, label, legend,
			table, caption, tbody, tfoot, thead, tr, th, td {
				margin:0;
				padding:0;
				border:0;
				outline:0;
				font-size:100%;
				vertical-align:baseline;
				background:transparent;
			}*/
			
			body {
				margin:0;
				padding:0;
				font:12px/15px "Helvetica Neue",Arial, Helvetica, sans-serif;
				color: #555;
				background:#f5f5f5 url('/static/img/bg.jpg');
			}
			
			a {color:#666;}
			
			#content {width:65%; max-width:690px; margin:6% auto 0;}
			
			/*
			Pretty Table Styling
			CSS Tricks also has a nice writeup: http://css-tricks.com/feature-table-design/
			*/
			
			table {
				overflow:hidden;
				border:1px solid #d3d3d3;
				background:#fefefe;
				margin:5% auto 0;
				-moz-border-radius:5px; /* FF1+ */
				-webkit-border-radius:5px; /* Saf3-4 */
				border-radius:5px;
				-moz-box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
				-webkit-box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
			}
			
			th, td {padding:10px 28px 0px; text-align:center; }
			
			th {padding-top:22px; text-shadow: 1px 1px 1px #fff; background:#e8eaeb;}
			
			td {border-top:1px solid #e0e0e0; border-right:1px solid #e0e0e0;}
			
			tr.odd-row td {background:#f6f6f6;}
			
			td.first, th.first {text-align:left}
			
			td.last {border-right:none;}
			
			/*
			Background gradients are completely unnecessary but a neat effect.
			*/
			
			td {
				background: -moz-linear-gradient(100% 25% 90deg, #fefefe, #f9f9f9);
				background: -webkit-gradient(linear, 0% 0%, 0% 25%, from(#f9f9f9), to(#fefefe));
			}
			
			tr.odd-row td {
				background: -moz-linear-gradient(100% 25% 90deg, #f6f6f6, #f1f1f1);
				background: -webkit-gradient(linear, 0% 0%, 0% 25%, from(#f1f1f1), to(#f6f6f6));
			}
			
			th {
				background: -moz-linear-gradient(100% 20% 90deg, #e8eaeb, #ededed);
				background: -webkit-gradient(linear, 0% 0%, 0% 20%, from(#ededed), to(#e8eaeb));
			}
			
			/*
			I know this is annoying, but we need additional styling so webkit will recognize rounded corners on background elements.
			Nice write up of this issue: http://www.onenaught.com/posts/266/css-inner-elements-breaking-border-radius
			
			And, since we've applied the background colors to td/th element because of IE, Gecko browsers also need it.
			*/
			
			tr:first-child th.first {
				-moz-border-radius-topleft:5px;
				-webkit-border-top-left-radius:5px; /* Saf3-4 */
			}
			
			tr:first-child th.last {
				-moz-border-radius-topright:5px;
				-webkit-border-top-right-radius:5px; /* Saf3-4 */
			}
			
			tr:last-child td.first {
				-moz-border-radius-bottomleft:5px;
				-webkit-border-bottom-left-radius:5px; /* Saf3-4 */
			}
			
			tr:last-child td.last {
				-moz-border-radius-bottomright:5px;
				-webkit-border-bottom-right-radius:5px; /* Saf3-4 */
			}
	    </style>
	    <link rel="shortcut icon" href="../assets/ico/favicon.ico">
	    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
	    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
	    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
	    <link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
  </head>
  <body class="">  
  	{include file="public:header"}
  	{include file="public:left"}
    <div class="content">  
        <div class="header">
            <div class="stats">
    			<p class="stat"><span class="number" id="date"></span>日</p>
   	 			<p class="stat"><span class="number" id="month"></span>月</p>
    			<p class="stat"><span class="number" id="year"></span>年</p>
			</div>
        	<h1 class="page-title">新闻管理</h1>
        </div>
       	<ul class="breadcrumb">
            <li><a href="index.html">Admin</a> <span class="divider">/</span></li>
            <li class="active">edit_new</li>
        </ul>
    	<div class="container-fluid">
        	<div class="row-fluid">
				<div style="float:right; margin-top: 1em;">
	    			<a href='{:url("admin/news/new_list")}' class="btn btn-danger">新闻列表</a>		   
	    			<a href='{:url("admin/news/add_new")}' class="btn btn-success">添加新闻</a>
	    			<a href='{:url("admin/newcate/nc_list")}' class="btn btn-primary">分类列表</a>
	    			<a href='{:url("admin/newcate/add_new_cates")}' class="btn btn-warning">添加分类</a>				    
				</div>
				<h3>&nbsp;&nbsp;&nbsp;编&nbsp;辑&nbsp;新&nbsp;闻</h3>
				<div id='calendar'>
					{assign name="i" value="1"}
					<table cellspacing="0px" border="1px" align="">
						<form action="" method="post" enctype="multipart/form-data" onsubmit="return check()">
							<tr>
								<td>分类父级:</td>
								<td>
									<select name="nc_id" id="nc_id" onblur="return iddd()">
										<option value="0">请选择分类</option>
										{foreach $cates as $v}
											<option value="{$v['id']}" {$data['nc_id']==$v['id']?"selected":""}>
												{$v['pc_name']}
											</option>
										{/foreach}
									</select>
									<span id="checknc_id"></span>
								</td>
							</tr>
							<tr>
								<td width="65px">新闻标题:</td>
								<td>
									<input type="text" name="new_name" id="new_name" value="{$data['new_name']}" onblur="return pc_name()">
									<span id="checkname"></span>
								</td>
							</tr>
							<tr>
								<td>标题内容:</td>
								<td>
									<textarea name="new_content" id="new_content" onblur="return pc_descrip()">{$data['new_content']}</textarea>
									<span id="checkdescrip"></span>
								</td>
							</tr>
							<tr>
								<td>&nbsp;图&nbsp;片&nbsp;库:</td>
								<td>
									<input type="file" name="pimgs[]" multiple='multiple' style="display:none" id="show">
									<br>
									{foreach $pimgs as $k=>$vo}
										&nbsp;&nbsp;&nbsp;&nbsp;
										<img src="{$vo}" width="100px" id="{$k}" title="单击删除">&nbsp;&nbsp;&nbsp;&nbsp;
										&nbsp;&nbsp;&nbsp;&nbsp;
										<script type="text/javascript">
											$("img[id='{$k}']").click(function(){
												v=$("#{$k}").attr("src")
												$("this").attr("title","");
												console.log(v)
												$.post("{:url('admin/news/edit_new')}","type=src&src="+v+"&id="+{$data.id},function(res){
														location.reload() ;
												})
											})
										</script>
									{/foreach}
									<span id="add">添加图片</span>
									</td>
							</tr>
							<tr>
								<td>&nbsp;发布人:</td>
								<td>
									<input type="text" name="issuer" id="issuer" value="{$data['issuer']}" onblur="return _issuer()">
									<span id="checkissuer"></span>

								</td>
							</tr>
							<tr>
								<td>&nbsp;关键词:</td>
								<td>
									<input type="text" name="keyword" id="keyword" value="{$data['keyword']}" onblur="return _keyword()">
									<span id="checkkey"></span>
								</td>
							</tr>
							<tr>
								<td>&nbsp;上&nbsp;下&nbsp;架:</td>
								<td>
									&nbsp;&nbsp;
									<input type="radio" name="ifshow" value="0"}>下架
									&nbsp;&nbsp;&nbsp;&nbsp;
									<input type="radio" name="ifshow" value="1" checked>上架
								</td>
							</tr>
							<tr>
								<td colspan="2" align="center"><input type="submit" name="sub" value="添加"></td>
							</tr>
						<form>
					</table>
				</div>                   
			    {include file="public:footer"}         
            </div>
        </div>
    </div>
    {load href="/static/js/bootstrap.js" /}
    <script type="text/javascript">
        $("[rel=tooltip]").tooltip();
        $(function() {
            $('.demo-cancel-click').click(function(){return false;});
        });
        var d=new Date
        $("#year").html(d.getFullYear())
        $("#month").html(d.getMonth()+1)
        $("#date").html(d.getDate())

        //添加图片
        $("#add").click(function(){
			$("input[id=show]").attr("style","display:''")
		})
        
		//正则验证
		var checksub=''
		var pricepreg=/^\d{1,}$/
		var i=""
		//验证父级
		function iddd(){
				v=$.trim($("#nc_id").val())
				console.log(v)
				if (v==='0') {
					$("#checknc_id").html("&nbsp;*请选择分类")
					$("#checknc_id").css("color","red")
					i=false
				}else{
					$("#checknc_id").html("&nbsp;√√√")
					$("#checknc_id").css("color","green")
					i=true
				}
		}		
		
		//验证标题
		function pc_name(){
			v=$.trim($("#new_name").val())
			if(v==''){
				$("#checkname").html("&nbsp;*标题不能为空")
				$("#checkname").css("color","red")
				i=false
			}else{
				$("#checkname").html("&nbsp;√√√")
				$("#checkname").css("color","green")
				i=true
			}
			// console.log(v)
		}
		
		//验证内容
		function pc_descrip(){
			v=$.trim($("#new_content").val())
			if(v==''){
				$("#checkdescrip").html("&nbsp;*不能为空")
				$("#checkdescrip").css("color","red")
				i=false
			}else{
				$("#checkdescrip").html("&nbsp;√√√")
				$("#checkdescrip").css("color","green")
				i=true
			}
		}
		//验证发布人
		function _issuer(){
			v=$.trim($("#issuer").val())
			if(v==''){
				$("#checkissuer").html("&nbsp;*不能为空")
				$("#checkissuer").css("color","red")
				i=false
			}else{
				$("#checkissuer").html("&nbsp;√√√")
				$("#checkissuer").css("color","green")
				i=true
			}
		}
		//验证关键字
		function _keyword(){
			v=$.trim($("#keyword").val())
			// alert(v.replace('//s/g',""));
			if(v==''){
				$("#checkkey").html("&nbsp;*不能为空")
				$("#checkkey").css("color","red")
				i=false
			}else{
				$("#checkkey").html("&nbsp;√√√")
				$("#checkkey").css("color","green")
				i=true
			}
		}
		
		function check(){
			iddd();
			pc_name()
			_issuer()
			_keyword()
			pc_descrip()
			return i;
		}


    </script>
  </body>
</html>


